program het
use imsl
implicit none

integer,parameter :: hh=69,nex=4,nobs=24,no=10
integer irank,iseed,a,b,c,d,e,f,g,h,istat,m,t,r,i,j,k,a1,a2,p,q,u,cc,dd,vv,rrr,tt,npc
real(8) master2(1123,15),t1,master1(44897,5),xbar,pid(204,1),pidcum(204,1),temp(1123,21),art1,art2,movieid(300,1),moviegenre(300,1)
real(8) t2,t3,t14(51,1)
open (35,file="C:\Documents and Settings\vn28\Desktop\movies collaborations\finalmoviesbyartistemoviesnew.txt",status="old",iostat=istat)
read (35,*) ((master2(j,i),i=1,15),j=1,1123)
open (22,file="C:\Documents and Settings\vn28\Desktop\movies collaborations\finalmoviesbyartistedetailednew.txt",status="old",iostat=istat)
!open (22,file="C:\Documents and Settings\vn28\Desktop\movies collaborations\ruf2.txt")
!open (22,file="C:\finalmoviesruf.txt")
read (22,*) ((master1(j,i),i=1,5),j=1,44897) !artisteid, yrofrel, movid, rev, prod budget, genre (0-7); writer(1,0)
!open (37,file="C:\writersnstats.txt")

c=1
do d=1,5
print *,master1(44897,c)
c=c+1
enddo

a=1
do b=1,1123
c=1
do d=1,15
temp(a,c)=master2(a,c)
c=c+1
enddo
a=a+1
enddo

!temp(a,16): no. of common movies b/w lead male (status=1) and writer
a=1
do b=1,1123
art2=temp(a,14) !writer id
if (temp(a,5).eq.1) then
art1=temp(a,6) !743
else
endif
if (temp(a,7).eq.1) then
art1=temp(a,8) !743
else
endif
if (temp(a,9).eq.1) then
art1=temp(a,10) !743
else
endif
if (temp(a,11).eq.1) then
art1=temp(a,12) !743
else
endif

c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,16)=temp(a,16)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,52)=temp(a,52)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second writer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,16)=temp(a,16)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,52)=temp(a,52)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

print *,"ok"

!temp(a,17): no. of common movies b/w lead female (status=2) and writer
movieid=0
a=1
do b=1,1123
art2=temp(a,14) !writer 1 id
if (temp(a,5).eq.2) then
art1=temp(a,6) !743
else
endif
if (temp(a,7).eq.2) then
art1=temp(a,8) !743
else
endif
if (temp(a,9).eq.2) then
art1=temp(a,10) !743
else
endif
if (temp(a,11).eq.2) then
art1=temp(a,12) !743
else
endif
c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,17)=temp(a,17)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,56)=temp(a,56)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second writer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,17)=temp(a,17)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,56)=temp(a,56)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo


!temp(a,18): no. of common movies b/w diro and writer
movieid=0
a=1
do b=1,1123
art2=temp(a,13) !writer id
art1=temp(a,13) !dir id

c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,18)=temp(a,18)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,59)=temp(a,59)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second writer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,18)=temp(a,18)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,59)=temp(a,59)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

!temp(a,19): no. of common movies b/w supporting male (status=3) and writer
movieid=0
a=1
do b=1,1123
art2=temp(a,14) !writer id
if (temp(a,5).eq.3) then
art1=temp(a,6) !743
else
endif
if (temp(a,7).eq.3) then
art1=temp(a,8) !743
else
endif
if (temp(a,9).eq.3) then
art1=temp(a,10) !743
else
endif
if (temp(a,11).eq.3) then
art1=temp(a,12) !743
else
endif
c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,19)=temp(a,19)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,62)=temp(a,62)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second writer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,19)=temp(a,19)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,62)=temp(a,62)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

!temp(a,20): no. of common movies b/w supporting female (status=3) and writer
movieid=0
a=1
do b=1,1123
art2=temp(a,14) !writer id
if (temp(a,5).eq.4) then
art1=temp(a,6) !743
else
endif
if (temp(a,7).eq.4) then
art1=temp(a,8) !743
else
endif
if (temp(a,9).eq.4) then
art1=temp(a,10) !743
else
endif
if (temp(a,11).eq.4) then
art1=temp(a,12) !743
else
endif
c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,20)=temp(a,20)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second producer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,20)=temp(a,20)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

!temp(a,21): no. of common movies b/w producer (status=3) and writer
movieid=0
a=1
do b=1,1123
art2=temp(a,14) !writer1 id
art1=temp(a,3) !producer1 id
c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,21)=temp(a,21)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second producer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,21)=temp(a,21)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

movieid=0
a=1
do b=1,1123
art2=temp(a,14) !writer1 id
art1=temp(a,4) !producer2 id
c=1
do d=1,44897
if(master1(c,1).eq.art1) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
e=e+1
movieid(e,1)=master1(c,3)
!moviegenre(e,1)=master1(c,6)!genre
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
e=0

c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,21)=temp(a,21)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
art2=temp(a,15) !second producer id
c=1
do d=1,44897
if(master1(c,1).eq.art2) then
if(master1(c,4).gt.0) then
if(master1(c,2).le.temp(a,2)) then !year of release
if(master1(c,2).gt.(temp(a,2)-8)) then !year of release
f=1
do g=1,300
if (movieid(f,1).eq.master1(c,3)) then
temp(a,21)=temp(a,21)+1
!if (moviegenre(f,1).eq.master1(c,6)) then
!temp(a,63)=temp(a,63)+1
!else
!endif
else
endif
f=f+1
enddo
else
endif
else
endif
else
endif
else
endif
c=c+1
enddo
a=a+1
enddo

write (37,1001)((temp(a,b),b=1,21),a=1,1123)
1001 format(21f15.3)
end program

